package com.example.controller;

import com.example.common.response.Result;
import com.example.model.dto.MessageDTO;
import com.example.model.dto.PageDTO;
import com.example.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/message")
public class MessageController {
    @Autowired
    private MessageService messageService;

    @GetMapping("/comments")
    public Result<PageDTO<MessageDTO>> getCommentMessages(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer pageSize) {
        Long userId = getCurrentUserId();
        PageDTO<MessageDTO> pageDTO = messageService.getCommentMessages(userId, page, pageSize);
        return Result.success(pageDTO);
    }

    @GetMapping("/likes")
    public Result<PageDTO<MessageDTO>> getLikeMessages(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer pageSize) {
        Long userId = getCurrentUserId();
        PageDTO<MessageDTO> pageDTO = messageService.getLikeAndCollectMessages(userId, page, pageSize);
        return Result.success(pageDTO);
    }

    @GetMapping("/follows")
    public Result<PageDTO<MessageDTO>> getFollowMessages(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer pageSize) {
            Long userId = getCurrentUserId();
        PageDTO<MessageDTO> pageDTO = messageService.getFollowMessages(userId, page, pageSize);
        return Result.success(pageDTO);
    }

    private Long getCurrentUserId() {
        return 1L;
    }
} 